package com.itfreer.gis.map.style.entity;

import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;

import com.itfreer.form.api.entity.EntityBase;
import com.itfreer.form.api.reflect.DictionaryField;

import javax.persistence.*;

/**
 * 定义我的样式实体
 */
@Entity(name = "gis_map_style")
public class MapStyleEntity extends EntityBase implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	@Id
	@Column(name = "id", length = 50, nullable = true)
	private String id;

	/**
	 * 名称
	 */
	@Column(name = "s_name", length = 50, nullable = true)
	private String name;

	/**
	 * 雪碧图地址
	 */
	@Column(name = "s_sprite", length = 50, nullable = true)
	@DictionaryField(dictionaryName = "p_sprite_directory", toFieldName = "spriteName")
	private String sprite;

	@Transient
	private String spriteName;

	/**
	 * 其他属性
	 */
	@Column(name = "s_propertys", nullable = true, columnDefinition = "text")
	private String propertys;

	/**
	 * 浏览器
	 */
	@Column(name = "s_browser", nullable = true)
	@DictionaryField(dictionaryName = "d_browser", toFieldName = "browserName")
	private String browser;

	/**
	 * 浏览器
	 */
	@Transient
	private String browserName;

	/**
	 * 终端
	 */
	@Column(name = "s_terminal", nullable = true)
	@DictionaryField(dictionaryName = "d_terminal", toFieldName = "terminalName")
	private String terminal;

	/**
	 * 终端
	 */
	@Transient
	private String terminalName;

	/**
	 * 最小内存要求
	 */
	@Column(name = "i_memory", nullable = true)
	private Integer memory;

	/**
	 * 内核-openlayers, mapbox, leaflet, ceisum
	 */
	@Column(name = "s_kernel", nullable = true)
	private String kernel;

	/**
	 * 外键
	 */
	@Column(name = "s_style_id", nullable = true)
	private String styleId;

	/**
	 * 排序
	 */
	@Column(name = "i_order", nullable = true)
	private Integer order;

	/**
	 * 是否有效
	 */
	@Column(name = "b_valid", nullable = true)
	private Boolean valid = true;

	/**
	 * 指定级别
	 */
	@Column(name = "i_zoom", nullable = true)
	private Integer zoom;

	/**
	 * 中心点
	 */
	@Column(name = "s_center", length = 100, nullable = true)
	private String center;

	/**
	 * 最大级别
	 */
	@Column(name = "i_maxzoom", nullable = true)
	private Integer maxZoom;

	/**
	 * 最小级别
	 */
	@Column(name = "i_minzoom", nullable = true)
	private Integer minZoom;

	/**
	 * 全图范围
	 */
	@Column(name = "s_extent", length = 200, nullable = true)
	private String extent;

	/**
	 * 数据源信息
	 */
	@SuppressWarnings("deprecation")
	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
	@org.hibernate.annotations.ForeignKey(name = "none")
	@JoinColumn(name = "s_style_id")
	@OrderBy("i_order ASC")
	private Set<MapStyleSourceEntity> sources = new LinkedHashSet<MapStyleSourceEntity>();

	/**
	 * 图层信息
	 */
	@SuppressWarnings("deprecation")
	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
	@org.hibernate.annotations.ForeignKey(name = "none")
	@JoinColumn(name = "s_style_id")
	@OrderBy("i_order asc")
	private Set<MapStyleLayerEntity> layers = new LinkedHashSet<MapStyleLayerEntity>();

	/**
	 * 租户ID
	 */
	@Column(name = "s_tenantid", length = 50, nullable = true)
	private String tenantID;

	/**
	 * 租户名称
	 */
	@Column(name = "s_tenantname", length = 50, nullable = true)
	private String tenantName;

	/**
	 * id
	 */
	public String getId() {
		return id;
	}

	/**
	 * id
	 */
	public void setId(String value) {
		this.id = value;
	}

	public String getSprite() {
		return sprite;
	}

	public void setSprite(String sprite) {
		this.sprite = sprite;
	}

	/**
	 * 其他属性
	 */
	public String getPropertys() {
		return propertys;
	}

	/**
	 * 其他属性
	 */
	public void setPropertys(String value) {
		this.propertys = value;
	}

	public Integer getMemory() {
		return memory;
	}

	public void setMemory(Integer memory) {
		this.memory = memory;
	}

	public String[] getKernel() {
		return super.getStringArray(this.kernel);
	}

	public void setKernel(String[] kernel) {
		this.kernel = getArrayString(kernel);
	}

	public String getStyleId() {
		return styleId;
	}

	public void setStyleId(String styleId) {
		this.styleId = styleId;
	}

	public Integer getOrder() {
		return order;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	public Integer getZoom() {
		return zoom;
	}

	public void setZoom(Integer zoom) {
		this.zoom = zoom;
	}

	public String getCenter() {
		return center;
	}

	public void setCenter(String center) {
		this.center = center;
	}

	public Integer getMaxZoom() {
		return maxZoom;
	}

	public void setMaxZoom(Integer maxZoom) {
		this.maxZoom = maxZoom;
	}

	public Integer getMinZoom() {
		return minZoom;
	}

	public void setMinZoom(Integer minZoom) {
		this.minZoom = minZoom;
	}

	public String getExtent() {
		return extent;
	}

	public void setExtent(String extent) {
		this.extent = extent;
	}

	public Set<MapStyleSourceEntity> getSources() {
		return sources;
	}

	public void setSources(Set<MapStyleSourceEntity> sources) {
		this.sources = sources;
	}

	public Set<MapStyleLayerEntity> getLayers() {
		return layers;
	}

	public void setLayers(Set<MapStyleLayerEntity> layers) {
		this.layers = layers;
	}

	@Transient
	public String[] getBrowserName() {
		return super.getStringArray(this.browserName);
	}

	public void setBrowserName(String[] browserName) {
		this.browserName = getArrayString(browserName);
	}

	@Transient
	public String[] getTerminalName() {
		return super.getStringArray(this.terminalName);
	}

	public void setTerminalName(String[] terminalName) {
		this.terminalName = getArrayString(terminalName);
	}

	public String[] getBrowser() {
		return super.getStringArray(this.browser);
	}

	public void setBrowser(String[] browser) {
		this.browser = getArrayString(browser);
	}

	public String[] getTerminal() {
		return super.getStringArray(this.terminal);
	}

	public void setTerminal(String[] terminal) {
		this.terminal = getArrayString(terminal);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Transient
	public String getSpriteName() {
		return spriteName;
	}

	public void setSpriteName(String spriteName) {
		this.spriteName = spriteName;
	}

	/**
	 * 是否有效
	 */
	public Boolean getValid() {
		return valid;
	}

	/**
	 * 是否有效
	 */
	public void setValid(Boolean isValid) {
		this.valid = isValid;
	}

	public String getTenantID() {
		return tenantID;
	}

	public void setTenantID(String tenantID) {
		this.tenantID = tenantID;
	}

	public String getTenantName() {
		return tenantName;
	}

	public void setTenantName(String tenantName) {
		this.tenantName = tenantName;
	}
}
